/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
 *
 * @brief load data instruction ut for ascend910B1
 *
 */
#include <gtest/gtest.h>
#include "kernel_operator.h"
#include "lib/matmul/tiling.h"
#include "impl/matmul/modules/matmul_param.h"
#include "impl/matmul/modules/input_cache/matmul_input_l1_cache.h"

using namespace std;
using namespace AscendC;
using namespace matmul;

#include "matmul_module_test_def.h"

namespace {

template <class A_TYPE, class B_TYPE, class C_TYPE, class BIAS_TYPE, const MatmulConfig& MM_CFG, class MM_CB>
class MatmulImpl
: MATMUL_IMPORT_MODULE(MatmulInputL1Cache, A_TYPE, B_TYPE) {
public:
    using VAR_PARAMS =
        typename MatmulParams<A_TYPE, B_TYPE, C_TYPE, BIAS_TYPE, MM_CFG, GetMatmulVersion(MM_CFG)>::PARAMS;

    MatmulImpl() {
        InitVar();
    }

    VAR_PARAMS& GetVar() {
        return var;
    }

    void AllocATensor() {
        var.cacheHeadA1_ = var.qidA1Cache_.template AllocTensor<typename A_TYPE::T>();
    }

    void AllocBTensor() {
        var.cacheHeadB1_ = var.qidB1Cache_.template AllocTensor<typename B_TYPE::T>();
    }

    void InitVar() {
        var.tiling_ = &tiling;
        var.tpipe_ = &pipe;
    }

private:
    TCubeTiling tiling;
    TPipe pipe;
    VAR_PARAMS var;
};
}

class test_matmul_input_l1_cache : public testing::Test {
protected:
    void SetUp() {}
    void TearDown() {}

private:
    using A_TYPE = matmul::MatmulType<AscendC::TPosition::TSCM, CubeFormat::ND, half>;
    using B_TYPE = matmul::MatmulType<AscendC::TPosition::TSCM, CubeFormat::ND, half>;
    using C_TYPE = matmul::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float>;
    using BIAS_TYPE = matmul::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float>;

    MatmulImpl<A_TYPE, B_TYPE, C_TYPE, BIAS_TYPE, CFG_NORM, void> mm;
};

TEST_F(test_matmul_input_l1_cache, first_iter_order_M) {
    mm.ClearAL1Cache();
    mm.ClearBL1Cache();
}